/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.synjones.pay.web.biz.transfer.helper;

import com.synjones.pay.model.transfer.TransferReqBean;
import com.synjones.pay.model.transfer.TransferRespBean;
import com.synjones.pay.web.biz.common.FailedVO;
import static com.synjones.pay.web.biz.common.PageParams.CLIENT_TYPE_WAP;
import com.synjones.pay.web.biz.common.WxRedisUserSnapBean;
import com.synjones.pay.web.biz.common.WxResponseBean;
import com.synjones.pay.web.biz.common.YktCardInfoBean;
import com.synjones.pay.web.biz.common.YktEaccInfoBean;

/**
 *
 * @author sxj
 */
public class TransferHelperBean {


    public static FailedVO getToTransferFailedVO(WxResponseBean respBean) {
        return new FailedVO(respBean.getErrCode(), respBean.getErrMsg());
    }

    public static FailedVO getTransferFailedVO(TransferRespBean tr) {
        return new FailedVO(tr.getStatusCode(), tr.getStatusDesc(), tr.getPaytoolCode(), tr.getOrderId(), tr.getCompleteTime());
    }
    
    public static TransferReqBean getTransferReqBean(WxResponseBean respBean,String appId,String device) {
        TransferReqBean trb = new TransferReqBean();
        WxRedisUserSnapBean userInfo = respBean.getData().getUserInfo();
        trb.setAppId(appId);
        trb.setClientType(CLIENT_TYPE_WAP);//2代表wap,即微校手机网页
        trb.setDevice(device);//设备信息从http中获取
        trb.setUcode(userInfo.getSchoolCode());
        trb.setUname(userInfo.getSchoolName());
        // amount 转账金额由页面确定
        // rollinAcc 转入账户由页面确定
        YktCardInfoBean cardInfo = respBean.getData().getCardInfos().get(0);//获取第一张卡信息
        YktEaccInfoBean eaccInfo = cardInfo.getEaccInfos().get(0);//获取第一张卡的第一个电子账户的信息
        trb.setRollinName(cardInfo.getCardname());//目前是设置成第一张卡的卡名称
        trb.setRolloutAcc(eaccInfo.getType());//第一张卡的第一个电子账户的电子账户号
        trb.setRolloutName(eaccInfo.getName());//第一张卡的第一个电子账户的电子账户名
        trb.setRemark("电子账户给卡转账");
        return trb;
    }

}
